package com.yonyou.hxjy.service.impl;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;

import com.yonyou.hxjy.entity.YsQueryDto;
import com.yonyou.hxjy.enums.OpenApiUrlEnum;
import com.yonyou.hxjy.service.BaseApi;
import com.yonyou.hxjy.utils.RequestTool;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;


@Component
public class YonsuiteService extends BaseApi {

    private static final Logger logger = LoggerFactory.getLogger(YonsuiteService.class);
    
    /**
     * @Author Huangwb
     * @Description 获取租户动态域名
     * @Date 11:13 2023/8/22
     **/
    public JSONObject getDynamicDomainName(HashMap<String, Object> params, String tenantId) throws Exception {
        return JSONUtil.parseObj(getRequestData1(RequestTool.doGet2("https://apigateway.yonyoucloud.com/open-auth/dataCenter/getGatewayAddress?tenantId=" + tenantId, params, false)));
    }

    /**
     * ys客户档案保存
     * @param params
     * @throws Exception
     */
    public JSONObject customerSave(Map<String, Object> params, YsQueryDto dto) throws Exception {
        return JSONUtil.parseObj( doPost(dto.getGatewayUrl() + OpenApiUrlEnum.CUSTOMER_SAVE, params, dto));
    }
    /**
     * ys客户档案详情查询
     * @param params
     * @throws Exception
     */
    public JSONObject customerQueryDetail(Map<String, Object> params, YsQueryDto dto) throws Exception {
        return JSONUtil.parseObj( doPost(dto.getGatewayUrl() + OpenApiUrlEnum.CUSTOMER_NEW_DETAIL, params, dto));
    }
    /**
     * ys员工详情查询
     * @param params
     * @throws Exception
     */
    public JSONObject staffQueryDetail(Map<String, Object> params, YsQueryDto dto) throws Exception {
        return JSONUtil.parseObj( doGet(dto.getGatewayUrl() + OpenApiUrlEnum.STAFF_DETAIL, params, dto));
    }

    /**
     * ys订单列表查询
     * @param params
     * @throws Exception
     */
    public JSONObject voucherOrderQueryList(Map<String, Object> params, YsQueryDto dto) throws Exception {
        return JSONUtil.parseObj(doPost(dto.getGatewayUrl() + OpenApiUrlEnum.SALES_ORDER_LIST, params, dto));
    }


    /**
     * ys供应商档案详情
     * @param params
     * @throws Exception
     */
    public JSONObject supplierQueryDetail(Map<String, Object> params, YsQueryDto dto) throws Exception {
        return JSONUtil.parseObj(doGet(dto.getGatewayUrl() + OpenApiUrlEnum.VENDOR_DETAIL, params, dto));
    }
    /**
     * ys部门案详情
     * @param params
     * @throws Exception
     */
    public JSONObject deptQueryDetail(Map<String, Object> params, YsQueryDto dto) throws Exception {
        return JSONUtil.parseObj(doGet(dto.getGatewayUrl() + OpenApiUrlEnum.DEPT_DETAIL, params, dto));
    }

    /**
     * 销售订单列表查询
     * @param params
     * @param dto
     * @return
     * @throws Exception
     */
    public JSONObject saleOrderQueryList (Map<String, Object> params, YsQueryDto dto) throws Exception {
        return JSONUtil.parseObj( doPost(dto.getGatewayUrl() + OpenApiUrlEnum.SALES_ORDER_LIST, params, dto));
    }






}
    

